# -*- coding: utf8 -*-
# $Id :  $



# Copyright 2008-2010, Pascal Fautrero & JCharles
#
# This file is part of PyArchiver.
# 
# PyArchiver is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyArchiver is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyArchiver.  If not, see <http://www.gnu.org/licenses/>.



# Import packages

import wx                        # This module uses the new wx namespace
import sys
import os

# import images                  # For PyEmbeddedImage

#_ = wx.GetTranslation           # Define _ or add _ to builtins in your app file

appDir = os.path.split(os.path.abspath(sys.argv[0]))[0]

#---------------------------------------------------------------------------

class My_InformationDialog(wx.Dialog):
    def __init__(self, parent, message, title, pos=wx.DefaultPosition,
                 size=wx.DefaultSize):
        wx.Dialog.__init__(self, parent, -1, title, pos, size)

        #-------------------------------------------------------------------

        self.ReturnValue = False
        self.parent = parent
        self.msg = message
        
        #-------------------------------------------------------------------

        # Simplified init method
        self.create_widget()
        self.do_layout()

        #-------------------------------------------------------------------
        
        self.Centre()
        
        #-------------------------------------------------------------------
        
        self.ReturnValue = not self.ShowModal()
        self.Destroy()

    #----------------------------------------------------------------------- 

    def create_widget(self):            
        self.panel = wx.Panel(self, -1)
        self.panel.SetBackgroundColour(wx.WHITE)

        #-------------------------------------------------------------------

        bitmapDir = os.path.join(appDir, "bitmaps")
        bmp = wx.Bitmap(os.path.join(bitmapDir, "logo_Information.png"))
        # or PyEmbeddedImage
        # bmp = images.Logo_Warning.GetBitmap()
        self.logo = wx.StaticBitmap(self.panel, -1)
        self.logo.SetBitmap(bmp)
        
        #-------------------------------------------------------------------
        
        self.warning = wx.StaticText(self.panel, -1,
                                     label=self.msg,
                                     style=wx.ALIGN_CENTRE)

        if wx.Platform == "__WXMAC__":
            pass

        else:
            font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
            font.SetWeight(wx.BOLD)
            self.warning.SetFont(font)
            self.warning.SetForegroundColour("#4f4f4f")
        
        #-------------------------------------------------------------------

        self.btnOK = wx.Button(self, id=wx.ID_OK, label="")
        self.btnOK.SetFocus()

    #-----------------------------------------------------------------------        

    def do_layout(self):       
        logoSizer = wx.BoxSizer(wx.VERTICAL)     
        logoTxtSizerH = wx.BoxSizer(wx.HORIZONTAL)
        logoTxtSizerV = wx.BoxSizer(wx.VERTICAL) 
        btnSizerH1 = wx.BoxSizer(wx.HORIZONTAL)
        btnSizerH2 = wx.BoxSizer(wx.HORIZONTAL)
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        
        #----------

        # wx.BoxSizer(window, proportion, flag, border)        
        # wx.BoxSizer(sizer, proportion, flag, border)         
        logoSizer.Add(self.logo, 0, wx.ALL, 10)        
        logoTxtSizerH.Add(logoSizer, 0, wx.ALIGN_CENTRE, 0)
        logoTxtSizerH.Add(self.warning, 1, wx.ALIGN_CENTRE | wx.EXPAND | wx.ALL, 15)
        logoTxtSizerV.Add(logoTxtSizerH, 1, wx.ALIGN_CENTRE | wx.EXPAND | wx.ALL, 10)
        btnSizerH1.Add(self.btnOK, 1, wx.TOP | wx.BOTTOM | wx.RIGHT, 10) 
        btnSizerH2.Add(btnSizerH1, 1, wx.ALL  | wx.ALIGN_RIGHT, 0)

        #----------
        
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.panel, 0, wx.ALL | wx.EXPAND, 0)
        mainSizer.Add(btnSizerH2,  1, wx.ALL  | wx.ALIGN_RIGHT, 0)
        
        #----------

        self.panel.SetAutoLayout(True)
        self.panel.SetSizer(logoTxtSizerV)
        logoTxtSizerV.Fit(self)
     
        #----------
        
        self.SetAutoLayout(True)
        self.SetSizer(mainSizer)
        mainSizer.Fit(self)
        
    #-----------------------------------------------------------------------

    def is_ok(self):
        return self.ReturnValue

    

